//I will go in NOIP
//by SIP zhangle from Class 7,Grade 7
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline ll read()
{
    ll x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x*f;
}
inline void write(ll x)
{
    if(x<0)
    {
        putchar('-');
        x=(~x)+1;
    }
    if(x>9)write(x/10);
    putchar(x%10+'0');
}
struct node
{
    ll l,r;
}q[100005];
ll d[100005],v[100005],a[100005],p[100005];
bool Mycmp(node x,node y)
{
    if(x.r!=y.r)return x.r<y.r;
    return x.l<y.l;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ll T=1,n,m,L,V,g,h,x,maxs,ans2,y;
    T=read();
    while(T--)
    {
        n=read();
        m=read();
        L=read();
        V=read();
        for(ll i=1;i<=n;i++)
        {
            d[i]=read();
            v[i]=read();
            a[i]=read();
        }
        for(ll i=1;i<=m;i++)p[i]=read();
        x=ans2=0;
        for(ll i=1;i<=n;i++)
        {
            if(a[i]==0)
            {
                if(v[i]>V&&d[i]<=p[m])
                {
                    g=lower_bound(p+1,p+m+1,d[i])-p;
                    h=m;
                    q[++x].l=g,q[x].r=h;
                }
            }
            else if(a[i]>0)
            {
                if((abs(V*V-v[i]*v[i]))%(abs(2*a[i]))==0)y=(V*V-v[i]*v[i])/(2*a[i])+1;
                else y=(V*V-v[i]*v[i])/(2*a[i]);
                if(y>=0)g=lower_bound(p+1,p+m+1,d[i]+y)-p;
                else g=lower_bound(p+1,p+m+1,d[i])-p;
                if(g==m+1)continue;
                h=m;
                q[++x].l=g,q[x].r=h;
            }
            else
            {
                if(v[i]<=V)continue;
                if((abs(V*V-v[i]*v[i]))%(abs(2*a[i]))==0)y=(V*V-v[i]*v[i])/(2*a[i])-1;
                else y=(V*V-v[i]*v[i])/(2*a[i]);
                g=lower_bound(p+1,p+m+1,d[i])-p;
                h=upper_bound(p+1,p+m+1,d[i]+y)-p-1;
                if(g==m+1||h==-1)continue;
                if(g<=h&&p[g]>=d[i]&&p[g]<=d[i]+y&&p[h]>=d[i]&&p[h]<=d[i]+y)q[++x].l=g,q[x].r=h;
            }
        }
        write(x);
        putchar(' ');
        sort(q+1,q+x+1,Mycmp);
        maxs=-1e18;
        for(ll i=x;i>=1;i--)
        {
            if(q[i].r<maxs)ans2++,maxs=-1e18;
            maxs=max(maxs,q[i].l);
        }
        if(x)write(m-(ans2+1));
        else write(m);
        putchar('\n');
    }
    return 0;
}
